package com.map;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.view.KeyEvent;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.tool.Alert;
import com.xinzhang.R;



public class MapOverlay extends Overlay  {
	private Resources resources;
	private GeoPoint geoPoint;
	private Context context;
	
	
	
	@Override
	public boolean onKeyUp(int keyCode, KeyEvent event, MapView mapView) {
		// TODO Auto-generated method stub
		Alert alert=new Alert(context);
		alert.show("test", "i am onclick");
		return super.onKeyUp(keyCode, event, mapView);
	}
	
	@Override
	
	public boolean onTap(GeoPoint p, MapView mapView) {
		// TODO Auto-generated method stub
		//Alert alert=new Alert(context);
		//a/lert.show("test", "i am onclick");
		return super.onTap(p, mapView);
	}
	
	
	
	public MapOverlay (Resources resources,GeoPoint geoPoint,Context context) {
		this.resources=resources;
		this.geoPoint=geoPoint;
		this.context=context;
		
	}
	
	
	
	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {

		super.draw(canvas, mapView, shadow);
		Point screenPts = new Point(); 
        mapView.getProjection().toPixels(geoPoint, screenPts); 
        Bitmap bmp = BitmapFactory.decodeResource( 
        		resources, R.drawable.point);            
        canvas.drawBitmap(bmp, screenPts.x-bmp.getWidth()/2, screenPts.y-bmp.getHeight()/2, null);    
       
	}
}
